﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LiuXingMain
{
    public partial class  ContactCFDFields
    {
        ConnectWallBase T;
        public  void SetParameter_wall()
        {
            if (!contact.ownerZone.continuum.isEnergyEnabled || !contact.neighborZone.continuum.isEnergyEnabled)
            {
                ComputeState.ReportInterrupt_FindError();
                LxConsole.WriteLine(LogTypes.错误, "边界未设置耦合");
            }
            if (contact.Thickness is Value1Const.Double vc && vc.number == 0)
            {
                LxTool.CheckCreateInstance<ConnectWallOneSide, ConnectWallBase>(ref T);
                var Ttemp = T as ConnectWallOneSide;
                Ttemp.CreateConnect(contact);
                Ttemp.setConnect(contact.S, contact.ownerZone.fields.T, contact.neighborZone.fields.T);
                AppRes.solveCenter.SeperatureTemperatureGroup.connectsTempStore.Add(Ttemp);
            }
            else
            {
                LxTool.CheckCreateInstance<ConnectWallTwoSide, ConnectWallBase>(ref T);
                var Ttemp = T as ConnectWallTwoSide;
                Ttemp.CreateConnect(contact);
                Ttemp.setConnect(contact.Tau, contact.Thickness, contact.S, contact.ownerZone.fields.T, contact.neighborZone.fields.T);
                AppRes.solveCenter.SeperatureTemperatureGroup.connectsTempStore.Add(Ttemp);
            }
        }
    }
}
//Ttarget checkCreate<Ttarget>() where Ttarget : ConnectWallBase, new()
//{
//    if (T is Ttarget treslut)
//    {
//        return treslut;
//    }
//    else
//    {
//        Ttarget trnew = new Ttarget();
//        T = trnew;
//        return trnew;
//    }
//}
//EquationBase getTMatrix(Mesh.Zone zone)
//{
//    if (zone.fields is FieldsInSolid solid)
//    {
//        return solid.T;
//    }
//    else if (zone.fields is FieldsInLaminarFlow flow)
//    {
//        return flow.T;
//    }
//    else
//    {
//        LxConsole.WriteLine(LogTypes.错误, "未找到温度场");
//        return null;
//    }
//}
//if (contact.ownerZone.fields is FieldsInSolid ownerSolidField && contact.neighborZone.fields is FieldsInSolid neighborSolidField)
//{
//}
//else
//{
//    throw new Exception(contact.name + "设置温度场失败");
//}
//ScalarBase_Ab extractAb(FieldsBase_InZone fieldsInZone)
//{
//    if (fieldsInZone is FieldsInSolid solid)
//    {
//        return solid.T;
//    }
//    else if (fieldsInZone is FieldsInLaminarFlow flow)
//    {
//        return flow.T;
//    }
//    else
//    {
//        return null;
//    }
//}
//T as ConnectOfTwoSideWall;
//if (Ttemp is null)
//{
//    Ttemp = new ConnectOfTwoSideWall();
//    T = Ttemp;
//}
//    T as ConnectOfOneSideWall;
//if (Ttemp == null)
//{
//    Ttemp = new ConnectOfOneSideWall();
//    T = Ttemp;
//}
//if (T == null)
//{
//    T1 = new ConnectOfOneSideWall();
//    T1.assignHeadAndCreateArray(contact);
//    T2 = null;
//}                  
//SolverControl.SeperatureTemperatureGroup.AddConnect(contact, contact.AMGSolverInContact, T1);
//if (T2 == null)
//{
//    T2 = new ConnectOfTwoSideWall();
//    T2.assignHeadAndCreateArray(contact);
//    T1 = null;
//}
//ConnectOfOneSideWall T1;
//ConnectOfTwoSideWall T2;